﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
// Copyright (C) 2021 kingerrobot
// 版权所有。 
//
// 文件名：BProdMaterial
// 文件功能描述：
//
// 创建者：名字 (zzl)
// 时间：2021/12/9 8:33:13
//
// 修改人：
// 时间：
// 修改说明：
// 版本：V1.0.0
//----------------------------------------------------------------*/
#endregion

using KingerRobot.MexicoSailunMDC.Dao;
using System;

namespace KingerRobot.MexicoSailunWMS.SpiService;

internal class BWmsPriorityCuring : IWmsPriorityCuring
{

    public List<POWmsPriorityCuring> GetAllPriorityCurings()
    {
        var db = Db.Default;
        var result = db.WmsPriorityCurings.Where(t => t.UseFlag == 1).ToList();
        return result;
    }
    public int DeletePriorityCuringById(long Id)
    {
        var db = Db.Default;
        var result = db.WmsPriorityCurings.Where(t => t.Id == Id).Delete();
        return result;
    }
    public int AddPriorityCuringById(priorityCuringParam param)
    {
        var db = Db.Default;

        var result = 0;

        if (db.WmsPriorityCurings.Where(t => t.CuringCode == param.CuringCode && t.UseFlag == 1).Count() > 0)
        {
            result = -1;
            return result;
        }
        result = db.WmsPriorityCurings.Insert(new POWmsPriorityCuring
        {
            Id = XID.Nextval,
            CuringCode = param.CuringCode,
            StartTime = param.StartTime,
            EndTime = param.EndTime,
            UseFlag = 1,
        });
        return result;
    }
    public int UpdatePriorityCuringById(priorityCuringParam param)
    {
        var db = Db.Default;
        var result = db.WmsPriorityCurings.Where(t => t.Id == param.Id).Update(new POWmsPriorityCuring
        {
            StartTime = param.StartTime,
            EndTime = param.EndTime,
        });
        return db.SaveChanges();
    }

}
